package com.david.zhufengfm.entity.discoverrecommend;

import com.david.zhufengfm.utils.EntityParseUtil;

import org.json.JSONArray;
import org.json.JSONException;
import org.json.JSONObject;

import java.util.LinkedList;
import java.util.List;

/**
 * Created by David on 2015/10/21.
 * qq:978944820
 */
/*
    "ret": 0,
    "title": "小编推荐",
    "hasMore": true,
    "list":[]
 */
public class DiscoverRecommendAlbums extends DiscoverRecommendItem{
    private int ret;
    private List<AlbumRecommend>albumRecommends;

    public void parseJson(JSONObject json) throws JSONException {
        //调用父类的解析，解析分类需要使用的数据
        //因为super中包含了title和hasMore
        super.parseJson(json);
        ret=json.optInt("ret",0);
        JSONArray array = json.getJSONArray("list");
        int len=array.length();
        albumRecommends=new LinkedList<>();
        for (int i = 0; i < len; i++) {
            JSONObject jsonObject=array.getJSONObject(i);
            AlbumRecommend albumRecommend= new AlbumRecommend();
            albumRecommend.parseJSON(jsonObject);
            albumRecommends.add(albumRecommend);

        }
    }

    public int getRet() {
        return ret;
    }

    public void setRet(int ret) {
        this.ret = ret;
    }

    public List<AlbumRecommend> getAlbumRecommends() {
        return albumRecommends;
    }

    public void setAlbumRecommends(List<AlbumRecommend> albumRecommends) {
        this.albumRecommends = albumRecommends;
    }
}
